<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<link href="${pageContext.request.contextPath}/res/lib/common/login/login.css" rel="stylesheet" type="text/css" />
 

<script type="text/javaScript"> 
if (window != top) 
top.location.href = location.href; 
</script> 

<title>首页</title>
</head>
<body>
<div class="login">

   <div class="login_title">
        <p>WEB基础平台框架</p>
    </div>
    <div class="login_main">
        <div class="main_left"></div>
        <div class="main_right">
            <div class="right_title">用户登录</div>
            <form action="./login_validate" onsubmit="return check()" method="post">
            	<div style="padding-bottom: 10px;">
       				 <label  style="margin-left: 50px;padding-left: 50px;color: red;">${error} </label>
        
      			</div>
                <div class="username">
                    <img src="${pageContext.request.contextPath}/res/lib/common/login/username.png" alt="">
                    <input type="text" id="user_id" name="user_id" placeholder="请输入用户名">
                </div>
                <div class="password">
                    <img src="${pageContext.request.contextPath}/res/lib/common/login/password.png" alt="">
                    <input type="password" id="user_pass" name="user_pass" placeholder="请输入密码">
                </div>
                <div class="code">
                    <img src="${pageContext.request.contextPath}/res/lib/common/login/code.png" alt="">
                    <input type="text" id="randomCode" name="randomCode" placeholder="请输入验证码">
                    <div class="code_img">
                        <img id="_v_code_img" src="${pageContext.request.contextPath}/randomcode.jpg" onclick="replaceCode()">
                        
                    </div>
                </div>
                <div class="yes_login">
                	 
                	 <input name="" type="submit" class="btn btn-success radius size-L" value="登&nbsp;&nbsp;&nbsp;&nbsp;录">
                </div>
            </form>
        </div>
    </div>
    <div class="login_footer">Copyright 你的公司名称  </div>
</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery/1.9.1/jquery.min.js"></script>  
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jsencrypt.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/public.js"></script>
 
 <script type="text/javascript">
 	function replaceCode() {
 		var timestamp = new Date().getTime();  
 		console.log('#############');
 		//document.getElementById().src='${pageContext.request.contextPath}/randomcode.jpg';
 		$("#_v_code_img").attr('src',$("#_v_code_img").attr('src') + '?'+ timestamp);
 	}
 	
 	
	function check() {
		
	 
		var userName = $("#user_id").val();
		   
		if(userName == null || userName == '') {
			 alert("用户名为空");   
			 return false;
		}
		var pass = $("#user_pass").val();
		if(pass == null || pass == '') {
			 alert("密码为空");   
			 return false;
		}
		var pat=new RegExp("[^a-zA-Z0-9\_\u4e00-\u9fa5]","i");   
		   
	      if(pat.test(userName)==true)   
	      {   
	          alert("用户名中含有非法字符");   
	          return false;   
	      }  
	      //判断验证码
	     var randomCode = $("#randomCode").val();
		if(randomCode == null || randomCode == '') {
			 alert("验证码为空");   
			 return false;
		}
	      
	  	var new_pass = encrypt(pass);
	  	 
		$("#user_pass").val(new_pass);
	      
	      
		return true;
		
	}
	
 	
 </script>
 
</body>
</html>